package com.atgao.commu.mapper;

import com.atgao.commu.mapper.mapper.DiscussPostMapper;
import com.atgao.commu.mapper.mapper.UserMapper;
import com.atgao.commu.mapper.pojo.DiscussPost;
import com.atgao.commu.mapper.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class userMapper1 {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private DiscussPostMapper discussPostMapper;
    @Test
    public void testSelectUser() {
        User user = userMapper.selectById(101);
        System.out.println(user);

        user = userMapper.selectByName("123");
        System.out.println(user);

//        user = userMapper.selectByEmail("nowcoder101@sina.com");
//        System.out.println(user);
    }

    @Test
    public void testSelectPosts() {
       //查询所有userid 是149 的帖子
        List<DiscussPost> list = discussPostMapper.selectDiscussPosts(149, 0, 10);
        for(DiscussPost post : list) {
            System.out.println(post);
        }
    //查询所有行数
        int rows = discussPostMapper.selectDiscussPostRows(149);
        System.out.println(rows);
    }
}
